<% size_font_header = 11 %>
<% size_font_general = 11 %>
<% form_tag catalogs_save_wish_list_path, :method => 'post' do %>

  <div class="portlet" style="width:100%;height:100%" id="catalog_material_list">
    <div class="portlet-header">
      <table style="border:none;width: 100%; color: black; font-size: <%="#{size_font_header}px"%>;">
        <tr style="vertical-align: bottom">
          <td align="left"><%= page_entries_info(@materials) %> </td>
          <td></td>
          <td align="right"><%= will_paginate(@materials, options_will_paginate({:params => {:controller => :catalogs, :action => :paginate_materials}, :outer_window => 1, :inner_window => 1})) %></td>
        </tr>
      </table>
    </div>

    <table style="width: 100%; font-size: <%="#{size_font_general}px"%>; border: 0; padding: 0">
      <tr>
        <td align="left" style="width: 25%">
          <a href="" onClick="$$('input.check').each(function(box){box.checked=true});return false;"><%=t('lbl_select_all')%></a> |
          <a href="" onClick="$$('input.check').each(function(box){box.checked=false});return false;"><%=t('lbl_deselect_all')%></a>
        </td>
        <td align="center">
          <% if !current_user.nil? %>
            <table style="border:none;" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left"><%=label_tag t('wish_list_selector')%></td>
                <td align="left"><%=select_tag('wish_list_selected', options_for_select([[t("lbl_select"), -1]] + @wish_lists.map {|u| if u.type_list != WishList::TYPE_SIMPLE then [t(u.name),u.id] else [u.name,u.id] end}), :style => "font-size:#{size_font_general}px;" ) %></td>
                <td align="left"><%=submit_tag t('lbl_save_wishlist'), :name => nil, :style => "font-size:#{size_font_general}px;" %> </td>
              </tr>
            </table>
          <% end %>
        </td>
        <td align="right">
            <%=  image_tag("load.gif", :align => "absmiddle", :border => 0, :id => "load_spinner", :style =>"display: none;" ) %>
            <%=  "#{t('order_method')}:" %>
            <%=  select_tag('catalog_material_order',
                            options_for_select(Material::ORDER_TYPES.map { |u| [t(u),u] },:selected => @order_type_selected),
                            :style => "font-size:#{size_font_general}px;",
                            :onchange => remote_function(:url => {:controller => :catalogs, :action => :sort_catalog},
                                                         :with=>"'order_type_selected='+this.value+''",
                                                         :update => 'table_material',
                                                         :before => "Element.show('load_spinner');",
                                                         :success => "Element.hide('load_spinner');"
                                                        )                            
                          )
            %>

        </td>
      </tr>
    </table>

    <table id="principalMaterialTable" style="width: 100%;height: 100%;vertical-align: top; border: 0; padding: 0">
      <% index = 0 %>
      <% @materials.each do |material| %>
      <% index += 1 %>
      <tr>
        <td>
          <table style="width: 100%; border-bottom: 0; border-left: 0; border-right: 0; border-top-width: 1px">
            <tr>
              <td align="left" style="vertical-align: top; width: 5px">
                <table style="vertical-align: top;border:0;padding: 0;">
                  <tr>
                    <td><%= check_box_tag "material_selected[]", material.id, false, :class => "check" %> </td>
                    <td><%="#{@materials.offset + index}."%></td>
                  </tr>
                </table>
              </td>
              <td align="left" style="vertical-align: top">
                <%=render :partial=>'materials/material_info_for_catalog', :locals => {:material => material} %>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <% end %>
    </table>
    <div class="portlet-footer" >
      <table cellspacing="0" cellpadding="0" style="width: 100%; border-bottom: 0; border-left: 0; border-right: 0; border-top-width: 1px; color: black; font-size: <%="#{size_font_header}px"%>;">
        <tr style="vertical-align: bottom">
          <td align="left"><%= page_entries_info(@materials) %> </td>
          <td align="right"><%= will_paginate(@materials, options_will_paginate({:params => {:controller => :catalogs, :action => :paginate_materials}, :outer_window => 1, :inner_window => 1})) %></td>
        </tr>
      </table>
    </div>
  </div>
<% end %>
